﻿Imports System.Data.SqlClient

Public Class CHoaDon
#Region "Atribute"
    Dim _iMaHoaDon As Integer
    Dim _dNgayNhap As DateTime
    Dim _iMaNhanVien As Integer
    Dim _iMaBan As String
    Dim _iTongTien As Integer
#End Region
#Region "Property"
    Property MaHoaDon As Integer
        Get
            Return _iMaHoaDon
        End Get
        Set(ByVal value As Integer)
            _iMaHoaDon = value
        End Set
    End Property
    Property NgayNhap As DateTime
        Get
            Return _dNgayNhap
        End Get
        Set(ByVal value As DateTime)
            _dNgayNhap = value
        End Set
    End Property

    Property MaNhanVien As Integer
        Get
            Return _iMaNhanVien
        End Get
        Set(ByVal value As Integer)
            _iMaNhanVien = value

        End Set
    End Property
    Property MaBan As String
        Get
            Return _iMaBan
        End Get
        Set(ByVal value As String)
            _iMaBan = value
        End Set
    End Property
#End Region
    Public Function InsertHoaDon(ByVal hd As CHoaDon) As Integer
        Dim da As New DataProvider
        Try
            da.OpenConnect()
            Dim sql As String = "INSERT INTO HOADON(NgayNhap,MaNhanVien,MaBan) VALUES(@NgayNhap,@MaNhanVien,@MaBan)"
            Dim cmd As New SqlCommand(sql, da.con)
            cmd.Parameters.AddWithValue("@NgayNhap", hd.NgayNhap)
            cmd.Parameters.AddWithValue("@MaNhanVien", hd.MaNhanVien)
            cmd.Parameters.AddWithValue("@MaBan", hd.MaBan)
            cmd.ExecuteNonQuery()
            Return 1
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Information, "Thông báo")
        Finally
            da.CloseConnect()
        End Try
        Return 0
    End Function
End Class
